package com.chris.filter;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import com.chris.util.SessionContext;

public class SessionListener implements HttpSessionListener,
		HttpSessionAttributeListener {

	public static void main(String[] args) {
	}

	public static Map userMap = new HashMap(); // 鍒涘缓浜嗕竴涓璞℃潵淇濆瓨session鐨�
	private SessionContext myc = SessionContext.getInstance(); // MySessionContext鏄疄鐜皊ession鐨勮鍙栧拰鍒犻櫎澧炲姞
																// 鍗曚緥妯″紡

	public void sessionCreated(HttpSessionEvent event) {
		System.out.println("addsesstion====");
		myc.AddSession(event.getSession());
		System.out.println("sid=" + event.getSession().getId());
	}

	public void sessionDestroyed(HttpSessionEvent event) {
		System.out.println("Destroyedsesstion====");
		HttpSession session = event.getSession();
		myc.DelSession(session);
	}

	/*
	 * 锛堥潪 Javadoc锛�
	 * 
	 * @see
	 * javax.servlet.http.HttpSessionAttributeListener#attributeAdded(javax.
	 * servlet.http.HttpSessionBindingEvent)
	 */
	public void attributeAdded(HttpSessionBindingEvent arg0) {
		// TODO 鑷姩鐢熸垚鏂规硶瀛樻牴

	}

	/*
	 * 锛堥潪 Javadoc锛�
	 * 
	 * @see
	 * javax.servlet.http.HttpSessionAttributeListener#attributeRemoved(javax
	 * .servlet.http.HttpSessionBindingEvent)
	 */
	public void attributeRemoved(HttpSessionBindingEvent arg0) {
		// TODO 鑷姩鐢熸垚鏂规硶瀛樻牴

	}

	/*
	 * 锛堥潪 Javadoc锛�
	 * 
	 * @see
	 * javax.servlet.http.HttpSessionAttributeListener#attributeReplaced(javax
	 * .servlet.http.HttpSessionBindingEvent)
	 */
	public void attributeReplaced(HttpSessionBindingEvent arg0) {
		// TODO 鑷姩鐢熸垚鏂规硶瀛樻牴

	}

}
